You can use the SPBOpenDevice function to open the default sound input device that the user has selected in the Sound In control panel or to open a specific sound input device. You must open a device before you can record from it by using SPBRecord , but the Sound Input Manager's high-level routines automatically open the default sound input device. You can close a sound input device by calling the SPBCloseDevice function.
You can use the SPBOpenDevice function to open a sound input device.
FUNCTION SPBOpenDevice (deviceName: Str255; permission: Integer;
VAR inRefNum: LongInt): OSErr;
The SPBOpenDevice function attempts to open a sound input device having the name indicated by the deviceName parameter. If SPBOpenDevice succeeds, it returns a device reference number in the inRefNum parameter. The permission parameter indicates whether subsequent operations with that device are to be read/write or read-only. If the device is not already in use, read/write permission is granted; otherwise, only read-only operations are allowed. To make any recording requests or to call the SPBSetDeviceInfo function, read/write permission must be available. Use these constants to request the appropriate permission:
CONST
siReadPermission = 0; {open device for reading}
siWritePermission = 1; {open device for reading/writing}
You can request that the current default sound input device be opened by passing either a zero-length string or a NIL string as the deviceName parameter. If only one sound input device is installed, that device is used. Generally you should open the default device unless you specifically want to use some other device. You can get a list of the available devices by calling the SPBGetIndexedDevice function.
Because the SPBOpenDevice function allocates memory, you should not call it at interrupt time.
You can use the SPBCloseDevice function to close a sound input device.
FUNCTION SPBCloseDevice (inRefNum: LongInt): OSErr;
The SPBCloseDevice function closes a device that was previously opened by SPBOpenDevice and whose device reference number is specified in the inRefNum parameter.
Because the SPBCloseDevice function moves or purges memory, you should not call it at interrupt time.
| Previous | Chapter contents | Chapter top | Section top | Next |